/*
 * 
 * NOT USED!
 */


package ciel.annotator;

import org.mt4j.components.visibleComponents.widgets.MTTextArea;
import org.mt4j.components.visibleComponents.widgets.MTTextArea.ExpandDirection;
import org.mt4j.components.visibleComponents.widgets.buttons.MTSvgButton;
import org.mt4j.components.visibleComponents.widgets.keyboard.ITextInputListener;
import org.mt4j.components.visibleComponents.widgets.keyboard.MTKeyboard;
import org.mt4j.components.visibleComponents.widgets.keyboard.MTTextKeyboard;
import org.mt4j.input.IMTInputEventListener;
import org.mt4j.input.inputData.MTInputEvent;
import org.mt4j.util.MTColor;
import org.mt4j.util.font.FontManager;

import ciel.debugging.CielDebugger;
import ciel.scene.CielImageScene;

import processing.core.PApplet;

public class CielTextAnnotator extends CielAnnotationModul {
	
	private PApplet pApplet;
	private MTKeyboard keyboard;
	private String filename;
	private CielImageScene scene;

	public CielTextAnnotator(PApplet pApplet, float width, float height, MTKeyboard keyboard, String filename, CielImageScene scene) {
		super(pApplet, width, height);
		this.pApplet = pApplet;
		this.keyboard = keyboard;
		this.filename = filename;
		this.scene = scene;
		title = "Titel und Notizen";
	}
	
	public void initKeyboard() {
		
		MTTextArea notes = new MTTextArea(pApplet, FontManager.getInstance().createFont(pApplet, "arial.ttf", 50, MTColor.BLACK)) {
			@Override
			public synchronized void appendCharByUnicode(String unicode) {
				// TODO Auto-generated method stub
				super.appendCharByUnicode(unicode);
				scene.setAnnotation(filename, getText());
			}
		}; 
		
		notes.setExpandDirection(ExpandDirection.UP);
		notes.setStrokeColor(new MTColor(0,0 , 0, 255));
		notes.setFillColor(new MTColor(205,200,177, 255));
		notes.unregisterAllInputProcessors();
		notes.setEnableCaret(true);
		addChild(notes);
		notes.setText(scene.getAnnotation(filename));
		
        keyboard.snapToKeyboard(notes);
        keyboard.addTextInputListener(notes);
	}
	
	protected void writeNote() {
		
	}

}
